package com.neardrug.exception;

import com.neardrug.common.Constants;
import com.neardrug.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author rui
 * @ClassName: GlobalExceptionHandler
 * @create 2023-06-28 17:32
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    //全局异常处理器
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handle(ServiceException se) {
        return Result.error(se.getCode(), se.getMessage());
    }
}
